class Solution
{
public:
    // 类似的题：435
    int findMinArrowShots(vector<vector<int>> &points)
    {
        auto compare = [](auto &l, auto &r)
        {
            if (l[1] == r[1])
            {
                return l[0] > r[0];
            }
            return l[1] < r[1];
        };
        sort(points.begin(), points.end(), compare);
        int selected = 1;
        int end = points[0][1];
        int n = points.size();
        for (int i = 1; i < n; ++i)
        {
            auto &interval = points[i];
            if (interval[0] > end)
            {
                ++selected;
                end = interval[1];
            }
        }
        return selected;
    }
};